<?php


namespace Biz\module\Classes\wiki;


use Doraemon\pockets\config\IniConfig;
use Doraemon\tools\Curl;
use Doraemon\tools\Log;

class WikiMiddle
{
    const CONFIG_FILE = 'recommendation_api';
    const CONFIG_SELECT = 'wiki';
    const PAGE_SIZE = 20;
    
    public static function getWikiIds($params, $tabType = null)
    {
        $wiki_ids = [];
        try {
            $url = self::getUrl($tabType);
            $result = Curl::Request('GET', $url . '?' . "wiki_id=" . $params['wiki_id'] . "&uid=" .$params['uid']);
            if ($result['code'] === 1) {
                $wiki_info = $result['json']['data'];
                $wiki_ids = $wiki_info['content_list'];
            }
        } catch (\Exception $e) {
            Log::error('wiki中间页：获取推荐wiki_ids失败', [
                'e_msg' => $e->getMessage(),
                'e_file' => $e->getFile(),
                'e_line' => $e->getLine()
            ]);
        }
        return $wiki_ids;
    }
    
    private static function getUrl($tabType)
    {
        $config = IniConfig::getConfigSelect(self::CONFIG_FILE, self::CONFIG_SELECT);
        return $config[$tabType];
    }
}